﻿using Microsoft.Extensions.Configuration;
using Ordering.Domain.AggregatesModel.OrderAggregate;
using Ordering.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ordering.API.Data
{
    public class OrderingDbContextSeed
    {
        public async Task SeedAsync(OrderingContext context, IConfiguration configuration)
        {
            if (!context.OrderStatuses.Any())
            {
                foreach (var status in GetOrderStatuses())
                {
                    context.OrderStatuses.Add(status);
                }
                await context.SaveChangesAsync();
            }
        }
        private IEnumerable<OrderStatus> GetOrderStatuses()
        {
            return new List<OrderStatus>
            {
                new OrderStatus(1,"下单"),
                new OrderStatus(2,"支付"),
                new OrderStatus(3,"接收订单"),
                new OrderStatus(4,"配送"),
                new OrderStatus(5,"完成"),
                new OrderStatus(6,"取消")
            };
        }
    }
}
